//
//  HomeWeatherView.m
//  DoctorOnline
//
//  Created by leergou on 16/7/5.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "HomeWeatherView.h"

@interface HomeWeatherView ()

/**
 *  weatherLabel
 */
@property (weak, nonatomic) UILabel *weatherLabel;


/**
 *  localeLabel
 */
@property (weak, nonatomic) UILabel *localeLabel;

/**
 *  weatherImgView
 */
@property (weak, nonatomic) UIImageView *weatherImgView;

/**
 *  temLabel
 */
@property (weak, nonatomic) UILabel *temLabel;

/**
 *  temLabel
 */
@property (weak, nonatomic) UILabel *dateLabel;

/**
 *   midLine
 */
@property (weak, nonatomic) UIView *midLine;

@end


@implementation HomeWeatherView

// 重写 init 方法
- (instancetype)init
{
    self = [super init];
    if (self) {
        
        //MARK: 1.添加子控件
        [self setupUI];
    }
    return self;
}

#pragma mark - 1.setupUI
- (void)setupUI{
    
    // weatherImgView
    UIImageView *weatherImgView = [[UIImageView alloc] initWithImage:nil];
    self.weatherImgView = weatherImgView;
    
    weatherImgView.backgroundColor = [UIColor yellowColor];
    
    [self addSubview:weatherImgView];
    
    // weatherLabel
    UILabel *weatherLabel = [[UILabel alloc] init];
    self.weatherLabel = weatherLabel;
    
    weatherLabel.font = [UIFont systemFontOfSize:20];
    weatherLabel.text = @"南京";
    weatherLabel.backgroundColor = [UIColor yellowColor];
    
    [self addSubview:weatherLabel];
    
    // localeLabel
    UILabel *localeLabel = [[UILabel alloc] init];
    self.localeLabel = localeLabel;
    
        localeLabel.text = @"天津";
    localeLabel.backgroundColor = [UIColor yellowColor];
    
    [self addSubview:localeLabel];
    
    // temLabel
    UILabel *temLabel = [[UILabel alloc] init];
    self.temLabel = temLabel;
    
        temLabel.text = @"上海";
    temLabel.backgroundColor = [UIColor yellowColor];
    
    [self addSubview:temLabel];
    
    // temLabel
    UILabel *dateLabel = [[UILabel alloc] init];
    self.dateLabel = dateLabel;
    
        dateLabel.text = @"背景";
    dateLabel.backgroundColor = [UIColor yellowColor];
    
    [self addSubview:dateLabel];
    
    // midLine
    UIView *midLine = [[UIView alloc] init];
    self.midLine = midLine;
    
    midLine.backgroundColor = [UIColor darkGrayColor];
    
    [self addSubview:midLine];
}


#pragma mark - 2.setLayout
- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self setLayout];
}
- (void)setLayout{
    
    [self.weatherImgView makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.left).with.offset(10);
        make.centerY.equalTo(self);
        make.height.width.equalTo(40);
    }];
    
    [self.weatherLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.weatherImgView.right).with.offset(5);
        make.centerY.equalTo(self);
        
        make.width.equalTo(50);
    }];
    
    [self.localeLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.weatherLabel.right).with.offset(30);
        make.centerY.equalTo(self);
        
        make.width.equalTo(50);
    }];
    
    [self.midLine makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self);
        make.centerY.equalTo(self);
        make.width.equalTo(1);
        make.height.equalTo(self.height).multipliedBy(0.8);
    }];
    
    [self.temLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.centerY).offset(-5);
        make.leading.equalTo(self.midLine).with.equalTo(20);
        
        make.trailing.equalTo(self.trailing);
    }];
    
    [self.dateLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.centerY).offset(5);
        make.leading.equalTo(self.midLine).with.equalTo(20);
        
        make.trailing.equalTo(self.trailing);
    }];
}


@end
